home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / Yerk 3.64 / Toolbox Classes / Radio < prev    next >
Text File  |  1991-11-16  |  2KB  |  69 lines

  1. \ radioSet groups a set of item numbers as a set of radio buttons
  2. \  7/24/85  cbd Changed on: and off: messages to put:
  3. \  7/24/85  cbd Added theDialog as an ivar
  4. \  5/23/90    rfl    Class Radio added for general radio buttons. RadioSet is for
  5. \                dialogs
  6. \            rfl    RadioSet stores the selected cell for use when dialog is newed
  7. \ 11\28\90    rfl added getItem: in radioset
  8. \ 11\13\91    rfl    added put: radio
  9.  
  10. \ general Radio button class
  11. :CLASS Radio <super ordered-col
  12.  
  13.     int     who-is-on    \ could use -1 for no selection
  14.  
  15. :M GET: get: who-is-on ;M
  16.  
  17. :M WITHIN: { ind -- b } ind limit < ind 0 >= and ;M
  18.  
  19. :M OFF: { ind - } ind within: self IF 0 put: [ ind at: self ] THEN ;M
  20.  
  21. :M ON:  { ind - } get: who-is-on off: self
  22.         ind within: self IF 1 put: [ ind at: self ] THEN ind put: who-is-on ;M
  23.  
  24. ( myctl -- )
  25. :M clickedOn: indexOf: self IF on: self THEN ;M
  26.  
  27. :M INIT: { ind - } size: self 0 do i off: self loop 1 put: [ ind at: self ]
  28.         ind put: who-is-on ;M
  29.  
  30. :M PUT: ( n --) put: who-is-on ;M
  31.  
  32. ( a1 a2... n -- )
  33. :M ACTIONS:  dup size: self > classErr" 129
  34.      0 do  actions: [ size: self 1- i - at: self ] loop
  35.      ;M
  36.  
  37. :M hilite: { on/off -- } limit 0 DO on/off hilite: [ i at: self ] LOOP ;M
  38.  
  39. ;CLASS
  40.  
  41. \ for use in dialogs
  42. :CLASS RadioSet  <Super byteCol
  43.  
  44.     Var        theDialog
  45.     int        SelectedCtl
  46.  
  47.     \ ( dialog -- )  associate this radio set with a Dialog
  48.     :M  INIT:  put: theDialog    ;M
  49.  
  50.     \ ( item# -- )  select radio button for item#
  51.     :M  SELECT: { item# -- }  size: self 0
  52.         DO  0  I at: Self   put: [ obj: theDialog ]
  53.         LOOP  1 item#  put: [ obj: theDialog ]  ;M
  54.  
  55.     \ ( -- item# )  return the radio button that was selected
  56.     :M  GET: { -- item# } size: self 0
  57.         DO  I at: self  get: [ obj: theDialog ]
  58.             IF I at: self leave THEN
  59.         LOOP    ;M
  60.  
  61.     :M  SET: get: selectedCtl select: self ;M
  62.  
  63.     :M  PUT: ( item# --) put: selectedCtl ;M
  64.  
  65.     :M  GETITEM: get: selectedCtl ;M
  66.  
  67. ;CLASS
  68.  
  69.